package com.ifnoelse.scheduler;

import java.util.concurrent.*;

/**
 * Created by ifnoelse on 2016/1/10.
 */
public class Job {
    private long interval = 0;
    private long delay = 0;

    public RunnableCallable getTask() {
        return task;
    }

    public void setTask(RunnableCallable task) {
        this.task = task;
    }

    private TimeUnit timeUnit;
    private ScheduledExecutorService executor;
    private RunnableCallable task;

    public TimeUnit getTimeUnit() {
        return timeUnit;
    }

    public void setTimeUnit(TimeUnit timeUnit) {
        this.timeUnit = timeUnit;
    }

    public void setInterval(long interval) {
        this.interval = interval;
    }

    public long getDelay() {
        return delay;
    }

    public void setDelay(long delay) {
        this.delay = delay;
    }

    public long getInterval() {
        return interval;

    }

    public Job second() {
        setTimeUnit(TimeUnit.SECONDS);
        return this;
    }

    public Job hour() {
        setTimeUnit(TimeUnit.HOURS);
        return this;
    }

    public Job minute() {
        setTimeUnit(TimeUnit.MINUTES);
        return this;
    }

    public Job day() {
        setTimeUnit(TimeUnit.DAYS);
        return this;
    }

    public Job(ScheduledExecutorService executor) {
        this.executor = executor;
    }

    public Job task(Runnable runnable) {
        this.task = new RunnableCallable(runnable);
        return this;
    }
}
